package cn.brilliantfuture.commentry.plan;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * 
 * Title: Communication Entry
 * 
 * Author: LiTian
 * 
 * Date: 2012-2-16
 * 
 * Description:
 * 
 */

public class InvokeDeliveryPlanJob implements Job {

	private static Logger logger = Logger.getLogger(InvokeDeliveryPlanJob.class);

	public void execute(JobExecutionContext jobec) throws JobExecutionException {
		logger.info("Start invoke delivery plan job now ...");

		try {
			Properties evn = new Properties();
			evn.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
			evn.put(Context.PROVIDER_URL, "127.0.0.1:1099");
			evn.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
			InitialContext ctx = new InitialContext(evn);
			DeliveryPlanMessageRemote deliveryPlanMessage = (DeliveryPlanMessageRemote) ctx.lookup("commentry-ear/DeliveryPlanMessageImpl/remote");
			deliveryPlanMessage.invokePlan();
		} catch (NamingException e) {
			logger.equals("Invoke delivery plan error -> " + e);
		}
	}
}
